const ApiDef = require('./impl')
const kong_cfg = configure.get('kong')

class serviceService {
    constructor (ctx) {
        this.apiBaseUrl = kong_cfg.kong_admin
    }

    add (data) {
        return ApiDef.post(`${this.apiBaseUrl}services`, data)
    }

    list () {
        return ApiDef.get(`${this.apiBaseUrl}services`)
    }

    get (name) {
        return ApiDef.get(`${this.apiBaseUrl}services/${name}`)
    }

    // 更新
    patch (name,data) {
        return ApiDef.patch(`${this.apiBaseUrl}services/${name}`, data)
    }

    // 更新或者创建
    put (name,data) {
        return ApiDef.put(`${this.apiBaseUrl}services/${name}`, data)
    }

    delete (name) {
        return ApiDef.delete(`${this.apiBaseUrl}services/${name}`)
    }
}

module.exports = new serviceService()

